local ClientOHOH = _G.ClientOHOH;

local M = ClientOHOH.class.new(script, ClientOHOH.files.OHOHOLYBUIBase());
local CommonOHOH =_G.CommonOHOH
local CallBackManager = ClientOHOH.load.CallBackManager();
local BtnHelper = ClientOHOH.load.BtnHelper();
local LanguageHelper=_G.LanguageHelper 
local ConnectClass=CommonOHOH.load.Connect();


function InitInsts(ui)
	ui.insts = {};
	ui.insts.close ="ctrl.close"
	ui.insts.name ="ctrl.name"
	ui.insts.pay1 ={
        price="ctrl.Price1.Price",
        count="ctrl.Price1.num",
        btn="ctrl.Price1.btn",
    }

	ui.insts.pay2={
        price="ctrl.Price2.Price",
        count="ctrl.Price2.num",
        btn="ctrl.Price2.btn",
    }
end

local  petPath="ctrl.pet"

function M.new(...)
	return M(...);
end;



function M.ctor(self,gui,eggName,price1,price2,count1,count2,cellList)
	InitInsts(self)

	M.super.ctor(self,gui);

    self.insts.PetSlots={}
    for _,v in pairs(self:WaitForChild_Loop(petPath):GetChildren()) do
        self.insts.PetSlots[tonumber(v.Name)]=v.Value
    end
    
    self.insts.name.Text=eggName
	CallBackManager:AddRbxConnect(self,self.insts.close.Activated, function()
		self:Hide()
	end);
	
    self.Pay1Event=ConnectClass.new()
    self.Pay2Event=ConnectClass.new()

    CallBackManager:AddRbxConnect(self,self.insts.pay1.btn.Activated, function()
        self.Pay1Event:Action()
	end);

    CallBackManager:AddRbxConnect(self,self.insts.pay2.btn.Activated, function()
        self.Pay2Event:Action()
	end);


    self.insts.pay1.price.Text=price1
    self.insts.pay1.count.Text="x"..count1

    self.insts.pay2.price.Text=price2
    self.insts.pay2.count.Text="x"..count2

    for k,cell in pairs(cellList) do
        cell:SetParent(self.insts.PetSlots[k])
    end
end;


function M.dtor(self)
	M.super.dtor(self);
end;



return M
